import { PageContainer } from '@ant-design/pro-layout';
import { Tag, Space } from 'antd';
import type { FC } from 'react';
import { history } from 'umi';
import React from 'react';
import styles from './style.less';
import ProList from '@ant-design/pro-list';
import { selectUsingPOST2 } from '@/services/api/Post';
import moment from 'moment';

type PostProps = {
  match: {
    url: string;
    path: string;
  };
  location: {
    pathname: string;
  };
};

const Post: FC<PostProps> = (props) => {
  // const { data: list } = useRequest(() => {
  //   return selectUsingPOST2();
  // });

  const getList = async (params: any) => {
    const res = await selectUsingPOST2({ ...params, valid: true });
    return res;
  };

  return (
    <PageContainer
      // 去除表头
      header={{
        title: '',
        breadcrumb: {},
      }}
    >
      {/* <AdvancedSearch onSearch={(value) => {getList(value)}} /> */}
      <div className={styles.standardList}>
        <ProList<any>
          onRow={(record: any) => {
            return {
              onMouseEnter: () => {
                console.log(record);
              },
              onClick: () => {
                console.log(record);
                history.push(`post/detail?id=${record.id}`);
              },
            };
          }}
          request={getList}
          pagination={{
            pageSize: 10,
          }}
          rowKey="id"
          split={true}
          size={'large'}
          search={{}}
          tooltip="基础列表的配置"
          showExtra="always"
          metas={{
            title: {
              dataIndex: 'name',
              title: '岗位名称',
            },
            description: {
              render: (text: any, record: any) => {
                return (
                  <div>
                    {record.education} | {record.degree}
                  </div>
                );
              },
              search: false,
            },
            subTitle: {
              render: (text: any, record: any) => {
                return (
                  <Space size={0}>
                    <Tag color="blue">{record.college}</Tag>
                    <Tag color="#5BD8A6">招{record.number}人</Tag>
                  </Space>
                );
              },
              search: false,
            },
            extra: {
              render: (text: any, record: any) => [
                <div>发布时间：{moment(record.utcCreate).format('YYYY-MM-DD HH:mm')}</div>,
              ],
              search: false,
            },
            college: {
              // 自己扩展的字段，主要用于筛选，不在列表中显示
              title: '学院',
              valueType: 'select',
              valueEnum: {
                信息与控制学院: { text: '信息与控制学院' },
                纺织服装学院: { text: '纺织服装学院' },
                经济管理学院: { text: '经济管理学院' },
                艺术与设计学院: { text: '艺术与设计学院' },
                人文与国际交流学院: { text: '人文与国际交流学院' },
                建筑工程学院: { text: '建筑工程学院' },
                后勤类: { text: '后勤类' },
              },
            },
          }}
        />
      </div>
    </PageContainer>
  );
};

export default Post;
